#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        vector <bool> tmp(n,false);
        vector <vector <bool>> cam(m,tmp);
        vector <pair <pair <int,int>,pair<int,int>>> car;
        set <int> overspeed;
        for(int i=0;i<n;i++)
        {
            int d,v,a;
            double s;
            cin>>d>>v>>a;
            if(a==0) s=L;
            else
            {
                double t=(double)(V-v)/(double)a;
                s=v*t+a*t*t/2.0+d;
            }
            car.push_back(make_pair(make_pair(d,s),make_pair(v,a)));
        }
        for(int i=0;i<m;i++)
        {
            int s;
            cin>>s;
            for(int j=0;j<n;j++)
            {
                if(car[j].second.second<0)
                {
                    if(car[j].second.first<=V) continue;
                    if(s>=car[j].first.first&&s<car[j].first.second)
                    {
                        overspeed.insert(j);
                        cam[i][j]=true;
                    }
                }
                else if(car[j].second.second==0)
                {
                    if(car[j].second.first<=V) continue;
                    if(s>=car[j].first.first&&s<=car[j].first.second)
                    {
                        overspeed.insert(j);
                        cam[i][j]=true;
                    }
                }
                else if(car[j].second.second>0)
                {
                    if(car[j].first.second>L) continue;
                    if(s>car[j].first.second)
                    {
                        overspeed.insert(j);
                        cam[i][j]=true;
                    }
                }
            }
        }
        int ans=0;
        while(1)
        {
            ans++;
            int mx=0;
            vector <bool> ind;
            for(int i=0;i<m;i++)
            {
                int cnt=0;
                for(int j=0;j<n;j++)
                {
                    if(cam[i][j]==true)
                        cnt++;
                }
                if(cnt>mx)
                {
                    mx=cnt;
                    ind=cam[i];
                }
            }
            if(mx==0) break;
            for(int i=0;i<m;i++)
            {
                    if(ind[i]==true)
                    {
                        for(int j=0;j<m;j++)
                        {
                            cam[j][i]=false;
                        }
                    }
            }
        }
        cout<<overspeed.size()<<' '<<m-ans+1<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
